package belf.migrate.api.table.schema;

import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/** 表示关系数据库表的元数据信息 */
@Data
@Builder
public final class TableSchema implements Serializable {
    private static final long serialVersionUID = 1L;
    private final List<ColumnMetaData> columns;

    private final PrimaryKey primaryKey;

    private final List<IndexKey> indexKeys;

    private final List<ForeignKey> foreignKeys;

    private final List<UniqueKey> uniqueKeys;

    private final List<CheckConstraint> checkConstraints;

    public String[] getFieldNames() {
        return columns.stream().map(ColumnMetaData::getColumnName).toArray(String[]::new);
    }

}
